import { Global } from "../../../../com/gengine/global/Global";
import { FilterConst } from "../../../component/gconst/FilterConst";
type int = number;
//class LineBox
    
    export  class LineBox /* flash.display.Sprite */
    {
        constructor()
        {
            
            this._lineLays = [];
            this._thumbParent = new Object /* flash.display.Sprite */();
            this.mouseChildren = false;
            this.mouseEnabled = false;
            this.cacheAsBitmap = true;
            return;
        }

        public updateLine(arg1: int, arg2: int, arg3: Array<any>, arg4: number=0.5, arg5: number=1, arg6: number=1): void
        {
            var loc1=0;
            var loc3=null;
            var loc4=0;
            this.dispose();
            this._refreshStep = arg4 * Global.stage.frameRate;
            var loc2=arg3.length;
            while (loc1 < loc2) 
            {
                loc4 = arg3[loc1];
                (loc3 = new Object /* flash.display.Sprite */()).graphics.lineStyle(arg5, loc4, arg6);
                loc3.graphics.drawRect(0, 0, arg1, arg2);
                loc3.graphics.endFill();
                loc3.filters = [FilterConst.colorGlowFilter(loc4)];
                this._lineLays.push(loc3);
                ++loc1;
            }
            this._lineNum = this._lineLays.length;
            if (this._lineNum != 1) 
            {
                if (this._lineNum > 1 && this._refreshStep > 0) 
                {
                    this.addEventListener(flash.events.Event.ENTER_FRAME, this.onEnterFrame);
                }
            }
            else 
            {
                this.addChild(this._lineLays[0]);
            }
            return;
        }

        /* internal  */onEnterFrame(arg1: Object /* flash.events.Event */): void
        {
            if (this._frameCount % this._refreshStep == 0) 
            {
                if (this._currentLine && this.contains(this._currentLine)) 
                {
                    removeChild(this._currentLine);
                }
                this._currentLine = this._lineLays[this._currentNum];
                addChild(this._currentLine);
                var loc1;
                var loc2=((loc1 = this)._currentNum + 1);
                loc1._currentNum = loc2;
                if (this._currentNum == this._lineNum) 
                {
                    this._frameCount = 0;
                    this._currentNum = 0;
                }
            }
            loc2 = ((loc1 = this)._frameCount + 1);
            loc1._frameCount = loc2;
            return;
        }

        public dispose(): void
        {
            var loc1=null;
            if (this.parent != this._thumbParent) 
            {
                this._thumbParent.addChild(this);
            }
            this._currentNum = 0;
            this._frameCount = 0;
            this._refreshStep = 0;
            this._lineNum = 0;
            this._lineLays.splice(0);
            if (this._currentLine) 
            {
                if (this._currentLine.parent) 
                {
                    removeChild(this._currentLine);
                }
                this._currentLine.filters = null;
                this._currentLine = null;
            }
            while (numChildren > 0) 
            {
                loc1 = this.removeChildAt(0) as Object /* flash.display.Sprite */;
                loc1 = null;
            }
            this.x = 0;
            this.y = 0;
            this.removeEventListener(flash.events.Event.ENTER_FRAME, this.onEnterFrame);
            return;
        }

        /* internal */ /* var */_lineLays: Array<any>;

        /* internal */ /* var */_lineNum: int;

        /* internal */ /* var */_currentNum: int;

        /* internal */ /* var */_refreshStep: int;

        /* internal */ /* var */_frameCount: int;

        /* internal */ /* var */_currentLine: Object /* flash.display.Sprite */;

        /* internal */ /* var */_thumbParent: Object /* flash.display.Sprite */;
    }
